/*
 * 本类记录所有商品信息的增删查方法
 * 2011-11-07:completed initially by gongshw
 */
package nju.mscs.data.object;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;

public class Inventory  implements Serializable{;
	/**
	 * 
	 */
	private static final long serialVersionUID = -5294179769261487025L;
	private	ArrayList<Goods> goodsList = new ArrayList<Goods>();
	
	protected Goods search(String id){
		for(Goods g:goodsList)
			if(g.getId().equals(id))
				return g;
		return null;
	}
	
	protected void add(String name,double price,String id,int amount){
		goodsList.add(new Goods(name,price,id,amount));
	}
	
	protected Iterator<Goods> getIterator(){
		return goodsList.iterator();
	}
	
	protected boolean delete(String id){
		return goodsList.remove(search(id));
	}

	protected boolean add(Goods object) {
		// TODO Auto-generated method stub
		return goodsList.add(object);
	}
}
